package com.zzl.bonds.ticket.feign;

import com.zzl.apidoc.annotation.ApidocOperation;
import com.zzl.bonds.ticket.dto.feign.FileInfoPar;
import com.zzl.general.common.feign.config.FeignClientsConfig;
import com.zzl.general.common.utils.Result;
import feign.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件中心的feign接口
 */
@FeignClient(value = "file", configuration = FeignClientsConfig.class)
public interface FileCenterFeign {
    /**
     * 上传文件到指定桶
     *
     * @param file   文件
     * @param bucket 桶
     * @return 响应数据
     */
    @PostMapping(value = "/file/allowAuth/upLoadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Result uploadFileMongo(@RequestPart(value = "file") MultipartFile file, @RequestParam("bucket") String bucket);

    /**
     * 下载图片 重新定义图片大小
     *
     * @param id     文件id
     * @param bucket 桶
     * @param width  宽
     * @param height 高
     * @return response 返回
     */
    @GetMapping("/file/allowAuth/downLoadImageResizeNoColor")
    Response downLoadImageResizeNoColor(@RequestParam("id") String id, @RequestParam("bucket") String bucket
            , @RequestParam("width") int width, @RequestParam("height") int height);

    /**
     * 不加权限的下载文件
     *
     * @param id     文件id
     * @param bucket bucket名
     */
    @GetMapping(value = "/file/allowAuth/downLoadFile")
    Response downloadFileMongoAllowAuth(@RequestParam("id") String id, @RequestParam("bucket") String bucket);

    @ApidocOperation(description = " 无权限 预览文件", operationId = "3")
    @GetMapping("/file/allowAuth/previewFile")
    Response previewFileNoAuth(@RequestParam("id") String id, @RequestParam("bucket") String bucket);

    /**
     * 通过文件桶和objId集合 获取文件名称等信息
     *
     * @param par 批量文件对象
     * @return 下载文件流
     */
    @PostMapping("/file/allowAuth/getFileByIds")
    Result getFileNameByIds(@RequestBody @Validated FileInfoPar par);
}
